#include "mainwindow.h"

void VoltageWheelThread::run()
{
    if(!ros2_stm32_talker_node_cpp)
    {
        ros2_stm32_talker_node_cpp = rclcpp::Node::make_shared("ros2_stm32_talker");
    }
    if(!voltage_pub_)
    {
        voltage_pub_ = ros2_stm32_talker_node_cpp->create_publisher<std_msgs::msg::Float32>("voltage_talker", 10);
    }
    auto voltage_data = std_msgs::msg::Float32();
    currentVoltageValue = currentVoltageValue * 10;
    if (currentVoltageValue <= 0 && currentVoltageValue >= -240)
    {
        voltage_data.data = -currentVoltageValue;
        voltage_pub_->publish(voltage_data);
    }
    else if (currentVoltageValue > 0 && currentVoltageValue <= 240)
    {
        voltage_data.data = currentVoltageValue + 240;
        voltage_pub_->publish(voltage_data);
    }
}
